#include "GameState/cGameState_Intro.h"

using namespace Ogre;

cGameState_Intro cGameState_Intro::mIntroState;

void cGameState_Intro::enter()
{
	mRoot = Root::getSingletonPtr();
	mSceneMgr = mRoot->getSceneManager("BaseSceneManager");
	mWindow = mRoot->getAutoCreatedWindow();
	mViewport = mWindow->getViewport(0);

	mViewport->setBackgroundColour(ColourValue(1.0, 1.0, 1.0));

	Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");

	SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	headNode->attachObject(ogreHead);

	// Set ambient light
	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

	// Create a light
	Light* l = mSceneMgr->createLight("MainLight");
	l->setPosition(20,80,50);

	mExitGame = false;
}

void cGameState_Intro::exit()
{
	mSceneMgr->clearScene();
}

void cGameState_Intro::pause()
{
}

void cGameState_Intro::resume()
{
}

bool cGameState_Intro::frameStarted(const FrameEvent& evt)
{
	//mKeyboard->capture();
	return true;
}

bool cGameState_Intro::frameEnded(const FrameEvent& evt)
{
	if (mExitGame)
		return false;

	return true;
}

void cGameState_Intro::keyPressed( const OIS::KeyEvent &e ) {
}

void cGameState_Intro::keyReleased( const OIS::KeyEvent &e ) {
    if( e.key == OIS::KC_ESCAPE ) {

        //mExitGame = true;
		changeState(&mIntroState);
    }
}

void cGameState_Intro::mouseMoved( const OIS::MouseEvent &e ) {
}

void cGameState_Intro::mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id ) {
}

void cGameState_Intro::mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id ) {
    
}